package com.dsunsoft.rtu.web;

import com.dsunsoft.rtu.common.entity.RestCode;
import com.dsunsoft.rtu.common.entity.RestResult;
import com.dsunsoft.rtu.entity.StPptnR;
import com.dsunsoft.rtu.entity.StRiverR;
import com.dsunsoft.rtu.query.DataQuery;
import com.dsunsoft.rtu.service.DataService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/data")
public class DataController {

    @Autowired
    private DataService dataService;

    @PostMapping("/pptn/page")
    public RestResult<PageInfo<StPptnR>> queryPageByPptn(@RequestBody DataQuery query) {
        PageInfo<StPptnR> page = dataService.queryPageByPptn(query);
        return new RestResult<>(RestCode.SUCCESS, page);
    }

    @PostMapping("/river/page")
    public RestResult<PageInfo<StRiverR>> queryPageByRiver(@RequestBody DataQuery query) {
        PageInfo<StRiverR> page = dataService.queryPageByRiver(query);
        return new RestResult<>(RestCode.SUCCESS, page);
    }
}
